{extend name="../admin/common/base" /}
{block name="body"}

{switch name="type"}
{case value="image"}
<form class="layui-form"  >
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-form-item">
                <label class="layui-form-label">图片：</label>
                <div class="layui-input-block">
                    {:hook('Upload',['type'=>'image','name'=>'m_image'])}
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="addMaterial">立即提交</button>
            </div>
        </div>
    </div>
</form>
{/case}

{case value="voice"}
<form class="layui-form"  >
    <div class="layui-form-item">
        <label class="layui-form-label">语音名称</label>
        <div class="layui-input-block">
            <input type="text" name="voice_title" value="{$material.title}" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-form-item">
                <label class="layui-form-label">音频：</label>
                <div class="layui-input-block">
                    {:hook('Upload',['type'=>'voice','name'=>'m_voice','bt_title'=>'上传语音','value'=>$material.url])}
                    <p class="tip_for_p">临时语音只支持amr/mp3格式,大小不超过为2M,长度不超过60秒,永久语音只支持mp3/wma/wav/amr格式,大小不超过为5M,长度不超过60秒</p>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="addMaterial">立即提交</button>
            </div>
        </div>
    </div>
</form>
{/case}
{case value="video"}
<form class="layui-form"  >
    <div class="layui-form-item">
        <label class="layui-form-label">视频标题</label>
        <div class="layui-input-block">
            <input type="text" name="video_title" value="{$material.title}" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">视频</label>
        <div class="layui-input-block">
            {:hook('Upload',['type'=>'video','name'=>'m_video','bt_title'=>'上传视频','value'=>$material.url])}
            <p class="tip_for_p">临时视频只支持mp4格式,大小不超过为10M,永久视频只支持rm/rmvb/wmv/avi/mpg/mpeg/mp4格式,大小不超过为20M</p>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">描述内容</label>
        <div class="layui-input-block">
            <textarea name="video_content" placeholder="请输入内容" class="layui-textarea">{$material.content}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="addMaterial">立即提交</button>
        </div>
    </div>
</form>
{/case}


{/switch}



<script>
    layui.use('form', function () {
        var form = layui.form;
        form.on('submit(addMaterial)', function (data) {
            $.post('',data.field,function (res) {

                if (res.status == 1) {
                    layer.msg(res.msg,{time:1000},function () {

                        window.location.href="{:url('index',['type'=>$type,'from_type'=>0])}";
                    });
                }else{
                    layer.alert(res.msg)
                }
            })
            return false;
        });
    });
</script>

{/block}